<?php include('includes/code/common.php'); ?>

<?php
$message='';
$successMessage='';
$errorOccurred=false;


	$fromName = '';
	$fromEmailAddress = '';
	$fromPhone ='';
	$subject ='';
	$comment='';
	
	//individual error messages
	$fromNameError = '';
	$fromEmailAddressError = '';
	$fromPhoneError ='';
	$fromContactError='';
	$subjectError ='';
	$commentError='';	

if (isset($_POST['submit']))
{
	//form was submitted
	$fromName = $_POST['fromName'];
	$fromEmailAddress = $_POST['fromEmailAddress'];
	$fromPhone =$_POST['fromPhone'];
	$subject ='Treadstone Web Site E-mail: '.' '.$_POST['subject'];
	$comment=$_POST['comment'];
	
	if (empty($fromName))
	{
		$message='*Please provide your name<br/>';
		$fromNameError='*Please provide your name';
		$errorOccurred=true;
	}
	
	if  ( (empty($fromPhone)) && (empty($fromEmailAddress)) ) 
	{
		$message=$message.'*Please provide some form of contact (e-mail address or phone)<br/>';
		$fromContactError = '*Please provide some form of contact (e-mail address or phone)';
		$errorOccurred=true;		
	}
	
	if (!empty($fromEmailAddress))
	{
		if (check_email_address($fromEmailAddress)==false)
		{
			$message=$message.'*Please provide a valid e-mail address<br/>';
			$fromEmailAddressError='*Please provide a valid e-mail address';
			$errorOccurred=true;				
		}
	}
	$phoneFormatted='';
	if (!empty($fromPhone))
	{
		
		if (!ereg('\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})',$fromPhone))
		{
			$message=$message.'*Please enter a valid phone number<br/>';
			$fromPhoneError='*Please enter a valid phone number';
			$errorOccurred=true;			
		}
	}
	
	if (empty($comment))
	{
		$message=$message.'*Please enter a message/question<br/>';
		$commentError='*Please enter a message/question';
		$errorOccurred=true;
	}	
	
	if ($errorOccurred==false)
	{
	
// Please specify your Mail Server - Example: mail.yourdomain.com.
ini_set("SMTP",$SMTPServer);

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","25");

// next two lines added by REW, CrystalTech
// Please specify the return address to use
ini_set('sendmail_from', 'questions@treadstoneweb.com');	

		//Proceed to send email
		
		$to = $GLOBALS['to_email_address'];
		$subject = $subject;
		$body = "This message was sent from the contact form on http://www.treadstoneweb.com.\n\nFrom: ".$fromName."\nPhone: ".$fromPhone."\nE-mail: ".$fromEmailAddress."\nMessage:\n".$comment;
		
		$mail_header = 'From: '.$fromName;
				
		
		if (mail($to, $subject, $body, $mail_header)) {
		  $successMessage ='Your message was successfully sent.';
		  
			$fromName = '';
			$fromEmailAddress = '';
			$fromPhone ='';
			$subject ='';
			$comment='';	
					  
		  
		 } else {
		  $message="An error occurred and your message was not successfully sent.";
	  
		 }		
		

		
	}
	
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Contact Treadstone Web Services</title>
<meta name="keywords" content="contact, Treadstone Web Services, Bloomington, Normal, Central Illinois" />
<meta name="description" content="Contact information and contact form for Treadstone Web Services" />
<meta name="robots" content="index,follow"/>
<meta http-equiv="expires" content="0"/>
<link rel="stylesheet" type="text/css" href="includes/css/yui_3.0.0_reset-min.css" /> 
<link href="includes/css/main.css" rel="stylesheet" type="text/css" media="screen" />
<link href="includes/css/print.css" rel="stylesheet" type="text/css" media="print" />
<script type="text/javascript" src="includes/javascript/jquery-1.2.6.min.js"></script>


<script type="text/javascript">
 $(document).ready(function() {
	$(":input, .formBlock").focus(function () {
         $(this).removeClass('normal').addClass('active');
    });
		$(":input, .formBlock").blur(function () {
         $(this).removeClass('active').addClass('normal');
    });
 });

</script>
</head>

<?php
	//top navigation selected
	$topNavSelected = "contactUs";
	
//Determining if a subject is present
$subject="";
if (isset($_GET['subj']))
{
	$subject='Treadtone E-mail Re: '.urldecode($_GET['subj']);
}
else
{
	if (isset($_POST['subject']))
	{
		$subject=$_POST['subject'];
	}
	else
	{
		$subject="Treadstone Web Site E-mail";
	}
}
	

	
?>

<body>

<!-- Container -->
<div id="container">

<!-- Header -->
<div id="header" title="Treadstone Web Services">

	<?php include('includes/headerContent.php') ?>

</div>
<!-- End Header -->

<div class="clear"></div>

<!-- Body -->
<div id="bodyContent">


<!-- Breadcrumbs -->
	<div id="breadcrumbs">
        <ul>
        	<li class="link"><a href="index.php" title="Home">Home</a></li>
            <li>Contact Us</li>
        </ul>
    </div>
<!-- End Breadcrumbs -->

	<div id="contentHome">
		
        <div class="section">
			<h1 >Contact Us</h1>
			
        		<?php
					if (!empty($message))
					{
						echo '<div class="message">';
						echo '<p>There were some errors in your form submission!</p>';
						echo '<p class="statusErrors">'.$message.'</p>';
						echo '</div>';
					}
					if (!empty($successMessage))
					{
						echo '<div class="successMessage">';
						echo '<p class="success">'.$successMessage.'</p>';
						echo '</div>';
					}					
				?>        
                            
            
            
            <h2>Treadstone Web Services</h2>
			
						
			<p>
			
			<img src="images/contactUs.png" title="Contact Us" alt="Contact Us" class="icon"/>
			
            1214 S Oak St<br/>
            Bloomingon, IL 61701<br/><br/>
            
            Contact : Lee Assam<br/>
            Phone: 309.212.6375<br/>
            E-mail: sales&#64;treadstoneweb.com<br/>
            </p>            
            
            <p>
            Call us today for a free estimate or to find out how we can make the "Web work for you"!
            </p>
			
            <p>
            You can also send us your questions or comments by utilizing the form below.<br/><br/>
            </p>
			
                                
        <div class="formBlock">

                  <form id="contact" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                  
                  <fieldset>
                  
                  <legend></legend>

                  
                  <div id="statusErrors"></div>                 
                  
                  	<ul>
                  
                   <li><label>To:</label> <span>Treadstone Web Services</span></li>                 

                   <li><label for="fromName" >From Name: <span class="requiredField">*</span> </label> 
                   
                   <input type="text"  name="fromName" maxlength="100" size="40" tabindex="1" value="<?php echo $fromName; ?>" id="fromName"  class="inputText" /><span class="errorMessage"><?php if (!empty($fromNameError)) { echo $fromNameError; } ?></span>
                   </li>
                   
                   <li>
                   <label for="fromEmailAddress" >From (E-mail Address):</label>
                   
                   <input type="text" name="fromEmailAddress" maxlength="100" size="40" tabindex="2" value="<?php echo $fromEmailAddress; ?>" id="fromEmailAddress" class="inputText" /><span class="errorMessage"></span>
                   </li>
                   
                    <?php if (!empty($fromEmailAddressError)) { ?>
                   
                   	<li><label>&nbsp;</label> <span class="errorMessage"><?php echo $fromEmailAddressError; ?></span></li>
                   
                   <?php } ?>    
                                            
                   <li>
                   <label for="fromPhone" >From (Phone) (xxx-xxx-xxxx):</label>
                   
                   <input type="text" name="fromPhone" size="12" tabindex="3" value="<?php echo $fromPhone; ?>" id="fromPhone"  class="inputText" /><span class="errorMessage" ><?php if (!empty($fromPhoneError)) { echo $fromPhoneError; } ?></span>
                   </li>           
                   
                    <?php if (!empty($fromContactError)) { ?>
                   
                   	<li><label>&nbsp;</label> <span class="errorMessage"><?php echo $fromContactError; ?></span></li>
                   
                   <?php } ?>                   
                   
                   <li>
                   <label for="subject" >Subject:</label>
                   
                   <input type="text" name="subject" size="50" tabindex="4" value="<?php echo $subject; ?>" id="subject" class="inputText"  /><span class="errorMessage"></span>
                   </li>       
                           
                                         
                   
                   <li>
                   <label for="comment" >Message: <span class="requiredField">*</span></label>
                   
                   <textarea name="comment" tabindex="5" cols="40" rows="10" id="comment" class="normal"><?php echo $comment; ?></textarea><span class="errorMessage"></span>
                   <br/>
                   </li>   
                   
                   <?php if (!empty($commentError)) { ?>
                   
                   	<li><label>&nbsp;</label> <span class="errorMessage"><?php echo $commentError; ?></span></li>
                   
                   <?php } ?>
                   
                   <li>
                   <label>&nbsp;</label><input type="submit" name="submit" id="submit" value="submit" tabindex="6"/>  
                   
                   </li>
                   
                   </ul>
                  
                  </fieldset>
                  
                  </form>
			</div> <!-- End of formBlock -->
                                
                                
                                
                                
                                
       </div>
       <!--   end #section-->
     </div>
	<!-- end #contentHome -->
	<div style="clear: both;">&nbsp;</div>
</div>
<!-- end #bodyContent -->
<!-- End Body -->

<div id="bodyEnd">&nbsp;
</div>
<!-- Footer -->
<div id="footer">
	<?php include('includes/footer.php') ?>
</div>
<!-- End Footer -->
</div>
<!-- End Container -->
<?php include('includes/googleAnalytics.php') ?>
</body>
</html>
